<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="display" uri="http://displaytag.sf.net" %>
<%
	String contextPath = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<link href="style/store.css" rel="stylesheet" type="text/css">
<link href="style/displaytagex.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
	function onLoadInit(){
		document.getElementById("c_name").focus();
	}
</script>
</head>
<body onload="onLoadInit();" >
	<s:form name="formName" method="post" >
	<s:hidden name="dispMode" />
	<s:hidden name="category.c_id" />
	<table align="center">
		<tr><td>
			<span class="error" >
				<s:actionerror/>
				<s:actionmessage/>
			</span>
		</td></tr>
	</table>
	<s:if test="dispMode == 1">
	<table align="center" width="45%">
		<tr>
			<td colspan="2" class="verdana" height="30" align="center" bgcolor="#336699">
				<font color="#ffffff">Category Maintenance</font>
			</td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Category Name: </label></td>
			<td><s:textfield name="category.c_name" id="c_name" label="Category Name" ></s:textfield></td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Description: </label></td>
			<td><s:textfield name="category.c_description" id="c_description" label="Description" ></s:textfield></td>
		</tr>
		<tr style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td colspan="2" ><s:submit cssClass="button" action="addCategoryAction" value="Add"></s:submit> </td>
		</tr>
	</table>
	<br/>
	<center>
	<s:set name="categoryList" value="categoryList" scope="request"></s:set>
	<display:table name="categoryList" uid="row" pagesize="10" class="dataTable"
	requestURI="goToCategoryAction.action">
		<display:column property="c_id" title="ID"></display:column>
		<display:column property="c_name" title="Category Name"></display:column>
		<display:column property="c_description" title="Description" sortable="true"></display:column>
		<display:column>
			<s:url id="update" action="goToUpdateCategoryAction">
						<s:param name="category.c_id" value="#attr.row.c_id"></s:param>
					</s:url>
					<s:a href="%{update}">Update</s:a>
					&nbsp; | &nbsp;
					<s:url id="delete" action="deleteCategoryAction">
						<s:param name="category.c_id" value="#attr.row.c_id"></s:param>
					</s:url>
					<s:a href="%{delete}" onclick="return confirm('Are you sure?')" >Delete</s:a>
		</display:column>
		<display:setProperty name="paging.banner.placement" value="bottom" />
	</display:table>
	</center>
	</s:if>
	<s:elseif test="dispMode == 2">
	<table align="center" width="45%">
		<tr>
			<td colspan="2" class="verdana" height="30" align="center" bgcolor="#336699">
				<font color="#ffffff">Update Category</font>
			</td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Category Name: </label></td>
			<td><s:textfield name="category.c_name" id="c_name" label="Category Name" ></s:textfield></td>
		</tr>
		<tr bgcolor="#e8ecf0" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td><label>Description: </label></td>
			<td><s:textfield name="category.c_description" id="c_description" label="Description" ></s:textfield></td>
		</tr>
		<tr style="font-size: 11px; font-family: Arial, Helvetica, sans-serif" >
			<td colspan="2" ><s:submit cssClass="button" action="updateCategoryAction" value="Update"></s:submit>
			<s:submit cssClass="button" action="goToCategoryAction" value="Cancel"></s:submit> </td>
		</tr>
	</table>
	</s:elseif>
	</s:form>
</body>
</html>